#define  _CRT_SECURE_NO_WARNINGS 1
#include "Hash.hpp"

namespace lw
{
	template<class K, class T, class Hash = Hash<K>, class Equal = Equal<K>>
	class unordered_map
	{
		struct MapKeyOfT
		{
			const K& operator()(const std::pair<K, T>& data)
			{
				return data.first;
			}
		};
	public:
		typedef typename HashBucket<K, std::pair<const K, T>, MapKeyOfT, Hash, Equal>::iterator iterator;
		unordered_map()
		{}
		~unordered_map()
		{}
		iterator begin()
		{
			return _hs.begin();
		}
		iterator end()
		{
			return _hs.end();
		}
		std::pair<iterator, bool> insert(const std::pair<K, T>& data)
		{
			return _hs.Insert(data);
		}
		bool erase(const K& key)
		{
			return _hs.Erase(key);
		}
		iterator find(const K& key)
		{
			return _hs.Find(key);
		}
		T& operator[](const K& key)
		{
			std::pair<iterator, bool> ret = insert(make_pair(key, T()));
			return ret.first->second;
		}

	private:
		HashBucket<K, std::pair<const K, T>, MapKeyOfT, Hash, Equal> _hs;
	};
}